<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	template="/WEB-INF/templates/general.xhtml">

	<ui:define name="title">
		<h:outputText value="Edit Static Data" />
	</ui:define>

	<ui:define name="content">
		<h:form enctype="multipart/form-data" id="form">
		
		
			<p:tabMenu activeIndex="1">
		        <p:menuitem value="Add New Results" url="new"/> 
		        <p:menuitem value="Edit Static Data" url="edit"/>  
	        </p:tabMenu>


			<table border="1px" style="margin: 10px 1%; width: 98%">
				<thead>
					<row>
						<td>
							<h3>Table List</h3>
						</td>
						<td>
							<p:commandButton value="Add Row" actionListener="#{table.render}" update="form" />
							<p:commandButton value="Delete" onclick="confirmation.show()" />
							<p:commandButton value="Commit" title="Commit to Database" actionListener="#{table.commit}" update="form"/>
						</td>
					</row>
				</thead>
				<tbody>
					<th rowspan="9" style="text-align: left; vertical-align: top;">
						<p:tieredMenu style="width: 300px">
					        <p:menuitem value="PERF_PROJECTNAME" disabled="true" />
					        <p:menuitem value="PERF_SCENARIO_TYPE" action="scenariotype" />
							<p:menuitem value="PERF_SCENARIO" action="scenario" />
							<p:menuitem value="PERF_TRANSACTION_TYPE" action="transactiontype" />
							<p:menuitem value="PERF_TRANSACTIONNAME" action="transactionname" />
							<p:menuitem value="PERF_TESTSUMMARY" action="testsummary" />
							<p:menuitem value="PERF_TESTSUMMARY_DATA" action="testsummarydata" />
							<p:menuitem value="PERF_TESTRESULTS" action="testresults" />
							<p:menuitem value="PERF_TESTRAWRESULTS" action="testrawresults" />
					    </p:tieredMenu>
					</th>
					<td>
						<p:dataTable id="table" var="project" value="#{table.projectNameModel}" selection="#{table.selectedProjectName}" editable="true" 
								editMode="cell" liveResize="true" paginator="true" rows="10" 
								paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                 				rowsPerPageTemplate="10,50,100">
							<p:ajax event="cellEdit" listener="#{table.onCellEdit}" />
							<p:column selectionMode="multiple" style="width:2%" />
						
							<p:column headerText="ID">
								<h:outputText value="#{project.PROJECT_ID}" />
							</p:column>
						
							<p:column headerText="Project Name">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{project.PROJECT_NAME}" /></f:facet>  
				                   <f:facet name="input"><p:inputText id="projectInput" value="#{project.PROJECT_NAME}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>

							<p:column headerText="Comments">
								<p:cellEditor>  
				                   <f:facet name="output"><h:outputText value="#{project.COMMENTS}" /></f:facet>  
				                   <f:facet name="input"><p:inputText id="commentsInput" value="#{project.COMMENTS}" style="width: 96%"/></f:facet>  
				               </p:cellEditor>
							</p:column>

						</p:dataTable> 
						
						<p:panelGrid id="add" columns="2" rendered="#{table.renderAddRow}" style="width: 100%">

							<f:facet name="header">  
						        Add Row
						    </f:facet>
						    
							<h:outputLabel for="name" value="Project Name" />
							<h:outputLabel for="sa" value="Comments" />
							
							<p:inputText id="name" value="#{table.PROJECT_NAME}" label="project Name" />
							<p:inputText id="sa" value="#{table.COMMENTS}" label="Comments" />

							<f:facet name="footer">
								<p:commandButton value="Add" actionListener="#{table.newProjectName}" update="table" />
							</f:facet>
						</p:panelGrid>
					</td>
				</tbody>
			</table>
			
			
			<p:commandButton value="Exit" title="Rollback Changes" actionListener="#{table.exit}" update="table" style="position: relavite; left: 90%;" />

			<p:confirmDialog id="confirmDialog"
				message="Are you sure you want to delete selected rows?"
				header="Delete selected rows" severity="alert"
				widgetVar="confirmation">

				<p:commandButton id="confirm" value="Yes" update=":form:table"
					actionListener="#{table.deleteSelected}" oncomplete="confirmation.hide()"
					 />
				<p:commandButton id="decline" value="Cancel"
					onclick="confirmation.hide()" type="button" />

			</p:confirmDialog>

			<p:messages id="messages" showDetail="false" autoUpdate="true"/> 
		</h:form>

	</ui:define>

</ui:composition>